<!-- 电子化文档生成 -->
<template>
  <div ref="electronDocCreateRef" class="electronDocCreate">
    <CertificateModal v-if="certificateVisible" :prj-params="prjParams" />
    <ReportModal v-if="reportVisible" :prj-params="prjParams" />
  </div>
</template>

<script>
import CertificateModal from '@/views/attachManagement/electronDocCreate/components/certificateModal.vue'
import ReportModal from '@/views/attachManagement/electronDocCreate/components/reportModal.vue'
import { getQueryObject } from '@/utils'
import { acceGenerationElectron } from '@/api/attachmentInfo'

export default {
    name: 'ElectronDocCreate',
    components: {
        CertificateModal,
        ReportModal
    },
    data() {
        return {
            certificateVisible: false, // 内部验收证书
            reportVisible: false, // 项目验收报告
            prjParams: {} // 页面路由参数集
        }
    },
    async created() {
        const {
            docType,
            prjId,
            nodeId,
            prjType
        } = getQueryObject()
        this.prjParams = {
            docType,
            prjId,
            nodeId,
            prjType
        }
        // await this.accGenerationElectron();
    },
    mounted() {
        if (this.prjParams.docType === 'D44') {
            this.certificateVisible = true
        } 
         if (this.prjParams.docType === 'D45') {
            this.reportVisible = true
        }
    },
    methods: {
        // 生成数据
        async accGenerationElectron() {
            const params = {
                prjId: this.prjParams.prjId,
                nodeId: this.prjParams.nodeId
            }
            await acceGenerationElectron(params).then(res => {
                if (+res.code !== 200) {
                    return Promise.reject(res)
                }
            })
        }
    }
}
</script>
<style scoped lang="scss">

</style>
